from django.urls import path
from rbac.views.auth import (
    user_login, user_logout, register, user_management, 
    account_info, dashboard
)
from rbac.views.role_management import (
    role_list, role_add, role_edit, role_delete, role_toggle_status,
    role_manage_permissions, get_role_permissions, permission_list,
    sync_all_permissions, clean_orphaned_permissions
)
from rbac.views.menu_management import (
    menu_list, menu_add, menu_edit, menu_delete, menu_toggle_status,
    get_menu_roles, welcome
)

app_name = 'rbac'

urlpatterns = [
    # 认证相关
    path('', dashboard, name='dashboard'),
    path('login/', user_login, name='login'),
    path('logout/', user_logout, name='logout'),
    path('register/', register, name='register'),
    
    # 用户管理
    path('user_management/', user_management, name='user_management'),
    path('account_info/', account_info, name='account_info'),
    
    # 角色管理
    path('role_list/', role_list, name='role_list'),
    path('role_add/', role_add, name='role_add'),
    path('role_edit/<int:role_id>/', role_edit, name='role_edit'),
    path('role_delete/<int:role_id>/', role_delete, name='role_delete'),
    path('role_toggle_status/<int:role_id>/', role_toggle_status, name='role_toggle_status'),
    path('role_manage_permissions/<int:role_id>/', role_manage_permissions, name='role_manage_permissions'),
    path('get_role_permissions/<int:role_id>/', get_role_permissions, name='get_role_permissions'),
    
    # 权限管理
    path('permission_list/', permission_list, name='permission_list'),
    path('sync_all_permissions/', sync_all_permissions, name='sync_all_permissions'),
    path('clean_orphaned_permissions/', clean_orphaned_permissions, name='clean_orphaned_permissions'),
    
    # 菜单管理
    path('menu_list/', menu_list, name='menu_list'),
    path('menu_add/', menu_add, name='menu_add'),
    path('menu_edit/<int:menu_id>/', menu_edit, name='menu_edit'),
    path('menu_delete/<int:menu_id>/', menu_delete, name='menu_delete'),
    path('menu_toggle_status/<int:menu_id>/', menu_toggle_status, name='menu_toggle_status'),
    path('get_menu_roles/<int:menu_id>/', get_menu_roles, name='get_menu_roles'),
    
    # 欢迎页面
    path('welcome/', welcome, name='welcome'),
]